<% layout('/layouts/default.html', {title: '车型管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa icon-notebook"></i> ${text('车型管理')}
			</div>
			<div class="box-tools pull-right">
				<% if(hasPermi('car:carType:edit')){ %>
					<a href="${ctx}/car/carType/form" class="btn btn-default btnTool" title="${text('新增车型')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
				<% } %>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${carType}" action="${ctx}/car/carType/listData" method="post" class="form-inline"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<#form:hidden path="typeCode"/>
				<div class="form-group">
					<label class="control-label">${text('归属大类')}：</label>
					<div class="control-inline width-120">
						<#form:select path="bigType" blankOptionLabel="全部" blankOption="true" dictType="h_big_type" blankOption="true" class="form-control isQuick"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('车型名称')}：</label>
					<div class="control-inline">
						<#form:input path="treeName" maxlength="200" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('状态')}：</label>
					<div class="control-inline width-120">
						<#form:select path="status" blankOptionLabel="全部" blankOption="true" dictType="sys_search_status" blankOption="true" class="form-control isQuick"/>
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm"><i class="glyphicon glyphicon-search"></i> ${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm isQuick"><i class="glyphicon glyphicon-repeat"></i> ${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
		</div>
	</div>
</div>
<% } %>
<script>
//# // 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'${text("车型名称")}', name:'treeName', index:'a.tree_name', width:250, align:"left", frozen:true, formatter: function(val, obj, row, act){
			return '<a href="${ctx}/car/carType/form?typeCode='+row.typeCode+'" class="btnList" data-title="${text("编辑分类")}">'+(val||row.id)+'</a>';
		}},
		{header:'${text("归属大类")}', name:'bigType', index:'a.big_type', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel("#{@DictUtils.getDictListJson('h_big_type')}", val, '${text("未知")}', true);
		}},
		{header:'${text("车型图片")}', name:'imgUrl', index:'a.img_url', width:150, align:"center", formatter: function(val, obj, row, act){
			if (val) {
				// 返回图片标签
				return '<img src="${baseUrl}' + val + '" style="max-width:80px;max-height:80px;border-radius:4px;" />';
			}else{
				return '-'
			}
		}},
		{header:'${text("车型推荐")}', name:'suggestStatus', index:'a.suggest_status', width:150, align:"center", formatter: function(val, obj, row, act){
				if (val === '1') {
					return '是';
				}else{
					return '-'
				}
			}},
		{header:'${text("排序号")}', name:'treeSort', index:'a.tree_sort', width:150, align:"center"},
		{header:'${text("状态")}', name:'status', index:'a.status', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel("#{@DictUtils.getDictListJson('sys_search_status')}", val, '${text("未知")}', true);
		}},
		{header:'${text("更新时间")}', name:'updateDate', index:'a.update_date', width:150, align:"center"},
		{header:'${text("备注信息")}', name:'remarks', index:'a.remarks', width:150, align:"left"},
		{header:'${text("操作")}', name:'actions', width:150, formatter: function(val, obj, row, act){
			var actions = [];
			//# if(hasPermi('car:carType:edit')){
				actions.push('<a href="${ctx}/car/carType/form?typeCode='+row.typeCode+'" class="btnList" title="${text("编辑车型")}"><i class="fa fa-pencil"></i></a>&nbsp;');
				if (row.status == Global.STATUS_NORMAL){
					actions.push('<a href="${ctx}/car/carType/disable?typeCode='+row.typeCode+'" class="btnList" title="${text("停用车型")}" data-confirm="${text("确认要停用该车型吗？")}"><i class="glyphicon glyphicon-ban-circle"></i></a>&nbsp;');
				} else if (row.status == Global.STATUS_DISABLE){
					actions.push('<a href="${ctx}/car/carType/enable?typeCode='+row.typeCode+'" class="btnList" title="${text("启用车型")}" data-confirm="${text("确认要启用该车型吗？")}"><i class="glyphicon glyphicon-ok-circle"></i></a>&nbsp;');
				}
				actions.push('<a href="${ctx}/car/carType/delete?typeCode='+row.typeCode+'" class="btnList" title="${text("删除车型")}" data-confirm="${text("确认要删除该分类及所有子车型吗？")}" data-deltreenode="'+row.id+'"><i class="fa fa-trash-o"></i></a>&nbsp;');
				if(row.treeLeaf=='0'){
                    actions.push('<a href="${ctx}/car/carType/form?parentCode='+row.id+'" class="btnList" title="${text("新增下级车型")}"><i class="fa fa-plus-square"></i></a>&nbsp;');
                }
			//# }
			return actions.join('');
		}}
	],
	treeGrid: true,			// 启用树结构表格
	defaultExpandLevel: 1,	// 默认展开的层次
	expandNodeClearPostData: 'bigType,treeName,remarks,', // 展开节点清理请求参数数据（一般设置查询条件的字段属性，否则在查询后，不能展开子节点数据）
});
</script>